package com.wframe.project.former.dataservices.floor;

import com.frame.database.JBaseService;
import com.frame.database.JServiceFactory;
import com.frame.database.JdataBean;
import com.frame.database.PageResult;
import com.frame.database.util.ConditionMap;
import com.wframe.project.jnd.entity.UiFloor;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/5/25.
 */
public class UiFloorService extends JBaseService<UiFloorDao> {
    public static UiFloorService getIntance() {
        return JServiceFactory.createJServiceProxy(UiFloorService.class);
    }

    public PageResult queryUiFloor(JdataBean pamrs, int size, int pageno) throws Exception {
        return getDao().queryUiFloor(pamrs, size, pageno);
    }
    public void upDateUiFloorStatus(String floorid,String state) throws Exception{
        getDao().upDateUiFloorStatus(floorid, state);
    }
    public void updateUifloorPanelState (String uifroolpenleid,String state) throws Exception{
        getDao().updateUifloorPanelState(uifroolpenleid, state);
    }

//    public List<JdataBean> queryPanel(String ui_floor_id) throws Exception{
//        return getDao().queryPanel(ui_floor_id);
//    }

    public List<JdataBean> queryPanel(String ui_floor_id) throws Exception {
        return getDao().queryPanel(ui_floor_id);
    }

    public List queryFloors(JdataBean bean) {
        return null;
    }

    public List queryFloorItem(String floorid) throws Exception {
        return getDao().queryPanelProducts(floorid);
    }

    public JdataBean getFloorItem(String id) throws Exception {
        return getDao().getFloorItem(id);
    }

    public void saveFloorItem(String panelId, String[] products) throws Exception {
        getDao().delFloorItemProducts(panelId);
        getDao().saveFloorItemProducts(panelId, products);
    }

    public void delFloorItem(String id) {

    }

    public PageResult queryFloorProduct(JdataBean parms, int size, int pageno) throws Exception {
        return getDao().queryFloorProduct(parms, size, pageno);
    }

    public void updatestatus(String id, int status) {
    }

    public String saveChannel(JdataBean bean) throws Exception{
        if(StringUtils.isBlank(bean.getString("id"))){
            return getDao().getSession().saveReturnKey("ui_floor_item",bean.getDataMap());
        }else{
            Map key=new HashMap();
            key.put("id", bean.getString("id"));
            getDao().getSession().update("ui_floor_item",bean.getDataMap(),key);
            return bean.getString("id");
        }
    }

    public JdataBean getChannel(String id) throws Exception {
        return getDao().getSession().getObject("select * from ui_floor_item where id=?", new Object[]{id});
    }
}
